package com.bsfcs.rag.enums;

import org.springframework.util.StringUtils;

public enum TaskState {
    TODO("0", "未启动"),
    IN_PROGRESS("1", "进行中"),
    DONE("2", "已完成"),
    CANCELLED("3", "逾期"),
    DEFAULT("", "");

    private final String code;
    private final String displayName;

    TaskState(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }

    public String getCode() {
        return code;
    }

    public String getDisplayName() {
        return displayName;
    }

    public static TaskState fromCode(String code) {
        if (!StringUtils.hasText(code)) {
            return null;
        }
        for (TaskState state : TaskState.values()) {
            if (state.getCode().equals(code)) {
                return state;
            }
        }
        return TaskState.TODO;
    }
}

